package com.example.demo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("redis集群测试")
@RestController
public class RedisController {
    @Autowired
    private RedisTemplate redisTemplate;

    @ApiOperation("set示例")
    @GetMapping("/set")
    public String set(String name) {
        redisTemplate.opsForValue().set("name", name);
        return name;
    }

    @ApiOperation("get示例")
    @GetMapping("/get")
    public Object get(String key) {
        return redisTemplate.opsForValue().get(key);
    }

}
